package phase3_testCase;

import static org.junit.Assert.*;

import java.util.Vector;

import org.junit.Before;
import org.junit.Test;

import phase3.Block;
import phase3.Dictionary;
import phase3.FindByPath;

public class FindByPath_testCase {

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testFindTheWords() {
		Block b1=new Block('a','b','c');
		Block b2=new Block('b','n','c');
		Block b3=new Block('a','b','t');
		Block b4=new Block('a','b','c');
		b1.setNextBlock(b2);
		b2.setNextBlock(b3);
		b3.setNextBlock(b4);
		
		FindByPath fbp=new FindByPath();
		Vector<String> test=new Vector<String>();
		Vector<String> expectedResult=new Vector<String>();
		
		expectedResult.add("aba");
		expectedResult.add("abb");
		expectedResult.add("abba");
		expectedResult.add("an");
		expectedResult.add("ant");
		expectedResult.add("act");
		
		fbp.findTheWords(b1, test, 4);
		//System.out.println(test);
		assertEquals(test,expectedResult);
	}

	@Test
	public void testFindTheWords2() {
		Block b1=new Block('a','a','c');
		Block b2=new Block('b','n','c');
		Block b3=new Block('a','b','t');
		Block b4=new Block('a','b','c');
		b1.setNextBlock(b2);
		b2.setNextBlock(b3);
		b3.setNextBlock(b4);
		
		FindByPath fbp=new FindByPath();
		Vector<String> test=new Vector<String>();
		Vector<String> expectedResult=new Vector<String>();
		
		expectedResult.add("aba");
		expectedResult.add("abb");
		expectedResult.add("abba");
		expectedResult.add("an");
		expectedResult.add("ant");
		expectedResult.add("act");
		
		fbp.findTheWords(b1, test, 4);
		//System.out.println(test);
		assertEquals(test,expectedResult);
	}
	@Test
	public void testFindTheWords3() {

        class BlockStub extends Block{
            @Override
            public int getNumOfChar()
            { 
                return 2;
            }
            public char getChar(int index)
            {
            	if(index==0)
            		return 'a';
            	else 
            		return 'n';

            }
    	
        };
		BlockStub b1=new BlockStub();
		BlockStub b2=new BlockStub();
		b1.setNextBlock(b2);

		
		FindByPath fbp=new FindByPath();
		Vector<String> test=new Vector<String>();
		Vector<String> expectedResult=new Vector<String>();
		
		expectedResult.add("an");
		//expectedResult.add("as");

		
		fbp.findTheWords(b1, test, 2);
		//System.out.println(test);
		assertEquals(test,expectedResult);
	}
	@Test
	public void testFindTheWords4() {

        class BlockStub extends Block{
            @Override
            public int getNumOfChar()
            { 
                return 2;
            }
            public char getChar(int index)
            {
            	if(index==0)
            		return 'a';
            	else 
            		return 's';

            }
    	
        };
		BlockStub b1=new BlockStub();
		BlockStub b2=new BlockStub();
		b1.setNextBlock(b2);

		
		FindByPath fbp=new FindByPath();
		Vector<String> test=new Vector<String>();
		Vector<String> expectedResult=new Vector<String>();
		
		expectedResult.add("as");
		//expectedResult.add("as");		
		fbp.findTheWords(b1, test, 2);
		//System.out.println(test);
		assertEquals(test,expectedResult);
	}
	@Test
	public void testFindTheWords5() {

        class BlockStub extends Block{
            @Override
            public int getNumOfChar()
            { 
                return 0;
            }
            public char getChar(int index)
            {
            	if(index==0)
            		return 'a';
            	else 
            		return 's';
            }
    	
        };
		BlockStub b1=new BlockStub();
		BlockStub b2=new BlockStub();
		b1.setNextBlock(b2);

		
		FindByPath fbp=new FindByPath();
		Vector<String> test=new Vector<String>();
		Vector<String> expectedResult=new Vector<String>();		
		//expectedResult.add("as");
		//expectedResult.add("as");		
		fbp.findTheWords(b1, test, 2);
		//System.out.println(test);
		assertEquals(test,expectedResult);
	}
	@Test
	public void testFindTheWords6() {

        class BlockStub extends Block{
            @Override
            public int getNumOfChar()
            { 
                return 1;
            }
            public char getChar(int index)
            {
            	if(index==0)
            		return 'a';
            	else 
            		return 's';
            }
    	
        };
		BlockStub b1=new BlockStub();
		BlockStub b2=new BlockStub();
		b1.setNextBlock(b2);

		
		FindByPath fbp=new FindByPath();
		Vector<String> test=new Vector<String>();
		Vector<String> expectedResult=new Vector<String>();
		
		fbp.findTheWords(b1, test, 2);
		assertEquals(test,expectedResult);
	}
}
